﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TR.AppService.AppService.Sys_Encode;
using TR.AppService.Dto;
using TR.AppService.Dto.SencDto;
using TR.Domain.Entity;

namespace TR.WebApi.Controllers.Sys_EncodeControllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Sys_EncodeController : ControllerBase
    {
        private readonly ISys_EncodeAppService sys_EncodeAppService;

        public Sys_EncodeController(ISys_EncodeAppService sys_EncodeAppService)
        {
            this.sys_EncodeAppService = sys_EncodeAppService;
        }

        //分页
        [HttpGet]
        public async Task<DtoFenYe<sys_Encode>> SEFCFenSelectAsync(int mys, int dqy, string qsj = null, string hsj = null, [FromQuery] SencFenyeTjDto senDto = null)
        {
            return await sys_EncodeAppService.EncodeFenYeSelectAsync(mys, dqy, qsj, hsj, senDto);
        }

        //编码ID查询
        [HttpGet]
        public async Task<sys_Encode> IdSelectAsync(int id)
        {
            return await sys_EncodeAppService.IDSelectAsync(id);
        }

        //修改
        [HttpPut]
        public async Task<bool> UpdeleteAsync([FromQuery] SencUpdateDto sen)
        {
            return await sys_EncodeAppService.UpdelectAsync(sen);
        }

        //条件查询
        [HttpGet]
        public async Task<sys_Encode> TjSelectAsync(string tj)
        {
            return await sys_EncodeAppService.TjSelectAsync(tj);
        }

        //编码规则新增
        [HttpPost]
        public async Task<bool> InsertAsync([FromQuery] SencInsertDto senadd)
        {
            return await sys_EncodeAppService.EncodeAddAsync(senadd);
        }
    }
}
